import 'package:flutter/material.dart';
import 'package:flutter_house_manager/api/home.dart';
import 'package:flutter_house_manager/componments/homeList.dart';
import 'package:flutter_house_manager/componments/homeNav.dart';
import 'package:flutter_house_manager/utils/toast.dart';
import 'package:fluttertoast/fluttertoast.dart';

class HomeView extends StatefulWidget {
  const HomeView({super.key});

  @override
  State<HomeView> createState() => _HomeViewState();
}

class _HomeViewState extends State<HomeView> {
  List _list = [];
  @override
  void initState() {
    super.initState();
    // 获取数据
    getAnnounceList();
  }

  getAnnounceList() async {
    final res = await getAnnounceListAPI();
    _list = res;
    setState(() {});
    

    // 弹出res的字符串
  }

  @override
  Widget build(BuildContext context) {
    return Container(
        color: Colors.white,
        child: Scaffold(
          appBar: AppBar(
            foregroundColor: Colors.black,
            centerTitle: true,
            backgroundColor: Colors.white,
            title: const Text('享+社区'),
          ),
          body: ListView(
            scrollDirection: Axis.vertical,
            children: [
              const Homenav(),
              Image.asset('assets/images/banner@2x.jpg'),
              Homelist(list:_list,),
            ],
          ),
        ));
  }
}
